package com.gc.business.service.impl;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.business.domain.ElevatorRepair;
import com.gc.business.domain.InventoryInfo;
import com.gc.business.service.IInventoryInfoService;
import com.gc.common.base.Result;
import com.gc.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.InventoryRecordMapper;
import com.gc.business.domain.InventoryRecord;
import com.gc.business.service.IInventoryRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 出入库记录 服务层实现
 * 
 * @author hruiyan
 * @date 2020-11-10
 */
@Slf4j
@Service
public class InventoryRecordServiceImpl extends ServiceImpl<InventoryRecordMapper, InventoryRecord> implements IInventoryRecordService {


    @Autowired
    private IInventoryInfoService inventoryInfoService;

    @Override
    public List<InventoryRecord> list(InventoryRecord inventoryRecord,List<Long> collect){
        LambdaQueryWrapper<InventoryRecord> wrapper = new LambdaQueryWrapper<>();
        if(inventoryRecord != null){
            if(StringUtils.isNotEmpty(inventoryRecord.getRecordId())){
                wrapper.eq(InventoryRecord::getRecordId, inventoryRecord.getRecordId());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getRecordType())){
                wrapper.eq(InventoryRecord::getRecordType, inventoryRecord.getRecordType());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getOrderNo())){
                wrapper.eq(InventoryRecord::getOrderNo, inventoryRecord.getOrderNo());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getItemName())){
                wrapper.like(InventoryRecord::getItemName, inventoryRecord.getItemName());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getItemNum())){
                wrapper.eq(InventoryRecord::getItemNum, inventoryRecord.getItemNum());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getRemainNum())){
                wrapper.eq(InventoryRecord::getRemainNum, inventoryRecord.getRemainNum());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getReceiver())){
                wrapper.like(InventoryRecord::getReceiver, inventoryRecord.getReceiver());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getDrawTime())){
                wrapper.eq(InventoryRecord::getDrawTime, inventoryRecord.getDrawTime());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getAuditor())){
                wrapper.like(InventoryRecord::getAuditor, inventoryRecord.getAuditor());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getAuditStatus())){
                wrapper.eq(InventoryRecord::getAuditStatus, inventoryRecord.getAuditStatus());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getRefuseReason())){
                wrapper.like(InventoryRecord::getRefuseReason, inventoryRecord.getRefuseReason());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getCreateBy())){
                wrapper.eq(InventoryRecord::getCreateBy, inventoryRecord.getCreateBy());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getCreateTime())){
                wrapper.eq(InventoryRecord::getCreateTime, inventoryRecord.getCreateTime());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getUpdateBy())){
                wrapper.eq(InventoryRecord::getUpdateBy, inventoryRecord.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getUpdateTime())){
                wrapper.eq(InventoryRecord::getUpdateTime, inventoryRecord.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getRemark())){
                wrapper.eq(InventoryRecord::getRemark, inventoryRecord.getRemark());
            }
            if(StringUtils.isNotEmpty(inventoryRecord.getInventoryId())){
                wrapper.eq(InventoryRecord::getInventoryId,inventoryRecord.getInventoryId());
            }
            if(CollUtil.isNotEmpty(collect)){
                //库存
                wrapper.in(InventoryRecord::getInventoryId,collect);
            }
        }
        return baseMapper.selectList(wrapper);
    }
}
